//注册页面功能
const mmm = document.querySelector('#btn-register')
mmm.addEventListener('click',async function(){
    const data = serialize(document.querySelector('.register-form'),{hash:true,empty:true})
    const {username,password} = data
    if(username == ''||password == '')return showToast('用户名或密码不能为空')
    if(username.length<8||username.length>30)return showToast('用户名不符合规定')
    if(password.length<6||password.length>24)return showToast('密码不符合规定')
    try {
        const res = await axios.post('/register',data)
        console.log(res)
        showToast(res.message)
    } catch (error) {
        showToast(error.response.data.message)
    }
})
const nnn = document.querySelector('.register-form')
nnn.addEventListener('keyup',async function(e){
    if(e.key == 'Enter'){
        mmm.click()
    }
})
